package com.sibbay.syncbox.adapter;

import junit.framework.TestCase;

import com.sibbay.syncbox.Config;
import com.sibbay.syncbox.utils.FileIterator;

public class IteratorTest extends TestCase {

	public void testIterator() {
		final FileIterator iter = new FileIterator(Config.SYNC_ROOT);
		final int cnt1 = countIterator(iter);
		final int cnt2 = countIterator(iter);

		assertEquals("iterator counter", cnt1, cnt2);
	}

	static int countIterator(final FileIterator iter) {
		int ret = 0;
		final boolean ret1 = iter.moveToFirst();
		assertTrue("directory has no files", ret1);

		while(true) {
			ret += 1;
//			System.out.println(iter.getFile().getAbsolutePath());
			if (!iter.moveToNext())
				break;
		}
		return ret;
	}
}
